﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace CommonUtils
{
    public static class TypeUtil
    {
        public static Type[] GetBases(this Type type)
        {
            var list = new List<Type>();
            while (type != null)
            {
                list.Add(type);
                type = type.BaseType;
            }
            return list.ToArray();
        }

        public static bool Contains(this Type type, Type baseType)
        {
            return type.GetBases().Contains(baseType);
        }
    }
}
